import 'package:flutter/material.dart';

void main() => runApp(const SnackBarBuilderWidget());

class SnackBarBuilderWidget extends StatelessWidget {
  const SnackBarBuilderWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter Demo",
      theme: ThemeData(
        primaryColor: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
            title: const Text("Flutter UI Widget -- SnackBar 及 Builder")),
        body: Builder(
          builder: (context) => ElevatedButton(
            child: const Text('Show SnackBar'),
            onPressed: () {
              ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
                  content: Text('SnackBar'), duration: Duration(seconds: 5)));
            },
          ),
        ),
      ),
    );
  }
}
